﻿using Excel2DbTool.Common;
using Excel2DbTool.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Excel2DbTool.Helpers
{
	/*
	public class CTableMigrater : DbTableMigrater
	{
		Dictionary<string, string> map = new Dictionary<string, string>()
		{
			{"LICENSENO","XMID"},
			{"XMMC","PROJECTNAME"},
		};


		public CTableMigrater()
		{
		}



		public override void Execute()
		{
			DataTable dt = GetDataWhichNeedInsertToTable();

			for (int i = 0; i < dt.Rows.Count; i++)
			{
				DbRowMapping dbrm = new DbRowMapping();

				for (int j = 0; j < dt.Columns.Count; j++)
				{
					var val = dt.Rows[i][j];
					dbrm.AddFieldMapping(new DbFieldMapping(val));
				}

				DbRowMappings.Add(dbrm);
			}


			InsertDataToDb();
		}

		DataTable GetDataWhichNeedInsertToTable()
		{
			string sql = String.Format("SELECT {0} FROM {1}", getFieldNeedRslove(), ConfigHelper.TableName);
			return SqlHelper.GetInstance().Select(sql);
		}

		String getFieldNeedRslove()
		{
			return string.Join(",", FieldMappings.Keys);
		}

		void InsertDataToDb()
		{
			String insertSql = "";
			SqlHelper.GetInstance().Insert(insertSql);
		}

	   
	}
	*/


	/*
	   -- Create table
	create table BDC_C
	(
	  cid     VARCHAR2(40) not null,
	  zrzid   VARCHAR2(36) not null,
	  ljzid   VARCHAR2(36) not null,
	  sjc     INTEGER,
	  myc     VARCHAR2(50),
	  cycjzmj FLOAT,
	  cscjzmj FLOAT,
	  ctnjzmj FLOAT,
	  cytmj   FLOAT,
	  cgyjzmj FLOAT,
	  cftjzmj FLOAT,
	  cbqmj   FLOAT,
	  cg      FLOAT,
	  sptymj  FLOAT,
	  cjsj    DATE,
	  cjr     VARCHAR2(50),
	  xgsj    DATE,
	  xgr     VARCHAR2(50),
	  xmid    VARCHAR2(36),
	  sftsc   INTEGER
	)
	tablespace BDCDJ0616
	  pctfree 10
	  initrans 1
	  maxtrans 255
	  storage
	  (
		initial 128K
		next 8K
		minextents 1
		maxextents unlimited
	  );
	-- Add comments to the columns 
	comment on column BDC_C.cid
	  is '层ID';
	comment on column BDC_C.zrzid
	  is '自然幢ID';
	comment on column BDC_C.ljzid
	  is '逻辑幢ID';
	comment on column BDC_C.sjc
	  is '实际层';
	comment on column BDC_C.myc
	  is '名义层';
	comment on column BDC_C.cycjzmj
	  is '层预测建筑面积';
	comment on column BDC_C.cscjzmj
	  is '层实测建筑面积';
	comment on column BDC_C.ctnjzmj
	  is '层套内建筑面积';
	comment on column BDC_C.cytmj
	  is '层阳台面积';
	comment on column BDC_C.cgyjzmj
	  is '层共有建筑面积';
	comment on column BDC_C.cftjzmj
	  is '层分摊建筑面积';
	comment on column BDC_C.cbqmj
	  is '层半墙面积';
	comment on column BDC_C.cg
	  is '层高';
	comment on column BDC_C.sptymj
	  is '水平投影面积';
	comment on column BDC_C.cjsj
	  is '创建时间';
	comment on column BDC_C.cjr
	  is '创建人';
	comment on column BDC_C.xgsj
	  is '修改时间';
	comment on column BDC_C.xgr
	  is '修改人';
	comment on column BDC_C.xmid
	  is '项目id';
	comment on column BDC_C.sftsc
	  is '是否特殊层 否：0    是：1';
	-- Create/Recreate primary, unique and foreign key constraints 
	alter table BDC_C
	  add constraint N_BDC_C_CID_PRI primary key (CID)
	  using index 
	  tablespace BDCDJ0616
	  pctfree 10
	  initrans 2
	  maxtrans 255
	  storage
	  (
		initial 64K
		next 1M
		minextents 1
		maxextents unlimited
	  );

	 */

}
